package com.qingxin.sys.support;

import java.util.HashMap;
import java.util.Map;

import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.map.annotate.JsonSerialize;

@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
public class JsTreeNode {

	private String id;
	private String parent;
	private String text;
	private String type;
	private String field;
	private Boolean children;
	private String custdata;
	private Map<String, Boolean> state;
	
	public JsTreeNode() {
		state = new HashMap<>();
	}
	
	
	public JsTreeNode(String id, String text, String type, String field, boolean children) {
		this.id = id;
		this.text = text;
		this.type = type;
		this.field = field;
		this.children = children;
		state = new HashMap<>();
		state.put("hasChildren", children);
	}
	
	public JsTreeNode(String id, String text,String parent, String type, String field, boolean children) {
		this.id = id;
		this.text = text;
		this.parent = parent;
		this.type = type;
		this.field = field;
		this.children = children;
		state = new HashMap<>();
		state.put("hasChildren", children);
	}
	

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getParent() {
		return parent;
	}

	public void setParent(String parent) {
		this.parent = parent;
	}

	public String getText() {
		return text;
	}

	public void setText(String text) {
		this.text = text;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String getField() {
		return field;
	}


	public void setField(String field) {
		this.field = field;
	}


	public Boolean getChildren() {
		return children;
	}

	public void setChildren(Boolean children) {
		this.children = children;
	}

	public String getCustdata() {
		return custdata;
	}


	public void setCustdata(String custdata) {
		this.custdata = custdata;
	}


	public Map<String, Boolean> getState() {
		return state;
	}

	public void setState(Map<String, Boolean> state) {
		this.state = state;
	}
	
	@JsonIgnore
	public void opened(){
		state.put("opened", true);
	}
	
	@JsonIgnore
	public void disabled(){
		state.put("disabled", true);
	}
	
	@JsonIgnore
	public void selected(){
		state.put("selected", true);
	}
	
	
}
